<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="标段（包）编号 " :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bidSectionCode">
              <a-input v-model="model.bidSectionCode" placeholder="请输入标段（包）编号 "  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="统一交易标识码 " :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unifiedDealCode">
              <a-input v-model="model.unifiedDealCode" placeholder="请输入统一交易标识码 "  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="标段（包）标识码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bidSectionId">
              <a-input v-model="model.bidSectionId" placeholder="请输入标段（包）标识码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="投标人名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bidderName">
              <a-input v-model="model.bidderName" placeholder="请输入投标人名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="投标人代码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bidderOrgCode">
              <a-input v-model="model.bidderOrgCode" placeholder="请输入投标人代码"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="缴纳金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginAmount">
              <a-input-number v-model="model.marginAmount" placeholder="请输入缴纳金额" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="缴纳币种 " :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginCurrency">
              <a-input v-model="model.marginCurrency" placeholder="请输入缴纳币种"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="缴纳时间 " :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginPayDate">
              <j-date placeholder="请选择缴纳时间"  v-model="model.marginPayDate" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="保证金缴纳账户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginPayAccount">
              <a-input v-model="model.marginPayAccount" placeholder="请输入保证金缴纳账户"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="保证金缴纳户名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginPayAccountName">
              <a-input v-model="model.marginPayAccountName" placeholder="请输入保证金缴纳户名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="保证金入账账户" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginReceiveAccount">
              <a-input v-model="model.marginReceiveAccount" placeholder="请输入保证金入账账户"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="保证金入账户名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginReceiveAccountName">
              <a-input v-model="model.marginReceiveAccountName" placeholder="请输入保证金入账户名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="缴纳状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginPayStatus">
              <a-input v-model="model.marginPayStatus" placeholder="请输入缴纳状态 "  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="保证金入账唯一标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="marginPayGuid">
              <a-input v-model="model.marginPayGuid" placeholder="请输入保证金入账唯一标识 "  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="交易系统标识码 " :labelCol="labelCol" :wrapperCol="wrapperCol" prop="platformCode">
              <a-input v-model="model.platformCode" placeholder="请输入交易系统标识码"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'ExBondPaysituationForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
           bidSectionCode: [
              { required: true, message: '请输入标段（包）编号 !'},
           ],
           unifiedDealCode: [
              { required: true, message: '请输入统一交易标识码 !'},
           ],
           bidSectionId: [
              { required: true, message: '请输入标段（包）标识码!'},
           ],
           bidderName: [
              { required: true, message: '请输入投标人名称!'},
           ],
           bidderOrgCode: [
              { required: true, message: '请输入投标人代码 》!'},
           ],
           marginAmount: [
              { required: true, message: '请输入缴纳金额!'},
           ],
           marginPayDate: [
              { required: true, message: '请输入缴纳时间 !'},
           ],
           marginPayAccount: [
              { required: true, message: '请输入保证金缴纳账户!'},
           ],
           marginPayAccountName: [
              { required: true, message: '请输入保证金缴纳户名!'},
           ],
           marginReceiveAccount: [
              { required: true, message: '请输入保证金入账账户!'},
           ],
           marginReceiveAccountName: [
              { required: true, message: '请输入保证金入账户名!'},
           ],
           marginPayStatus: [
              { required: true, message: '请输入缴纳状态'},
           ],
           marginPayGuid: [
              { required: true, message: '请输入保证金入账唯一标识 !'},
           ],
           platformCode: [
              { required: true, message: '请输入交易系统标识码 !'},
           ],
        },
        url: {
          add: "/exBond/exBondPaysituation/add",
          edit: "/exBond/exBondPaysituation/edit",
          queryById: "/exBond/exBondPaysituation/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>